Skip to content

Report a stopped CloudStack instance as shut down - #120

Open
bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:ccm-instance-shutdown
Open

bhouse-nexthop wants to merge 1 commit into
apache:mainfrom
bhouse-nexthop:ccm-instance-shutdown

Conversation

@bhouse-nexthop

Copy link
Copy Markdown

InstanceShutdown and InstanceShutdownByProviderID returned NotImplemented. When a node's VM was stopped in CloudStack, the node lifecycle controller could not tell it from an unreachable node: it never applied node.cloudprovider.kubernetes.io/shutdown, and on the InstancesV2 path it logged error checking if node <name> is shutdown: unimplemented for every NotReady node on each monitor period.

Both now look up the instance and report it shut down when its state is Stopped.

Instance state Before After
Stopped error unimplemented shut down: the node gets the taint
Starting, Running, Stopping, Migrating error unimplemented not shut down
not found error unimplemented InstanceNotFound
  • Stopping is not shut down: the guest may still be running and writing to its volumes.
  • InstanceShutdown finds the instance by node name, as InstanceExists does. The controller calls both on the same node, so they look at the same VM, and it works on nodes without a provider ID.
  • The controller removes the taint itself once the node is Ready again.

Testing

  • make test: all tests pass, 0 failures; 18 new subtests: state mapping, node unknown to CloudStack, API errors, instance deleted between lookups, and InstanceShutdownByProviderID in the existing lookup table (project scoping, scheme stripping, not found, API error).
  • make lint (golangci-lint 2.15.0): 0 issues.
  • Not yet tested on a cluster. I'll add a test report: stop a worker VM, check the taint appears, start it, check the taint goes.

Not done

  • The shutdown taint is NoSchedule only. It doesn't release a stopped node's volumes; that is Kubernetes' node.kubernetes.io/out-of-service taint.
  • With a root-admin API key, a destroyed but not yet expunged VM is still listed, so the node is reported as existing and not shut down. With an account key (as CKS uses) it isn't listed.
  • InstanceExists still returns an error rather than false when the node's VM is gone. That is a separate change.

Fixes #119

InstanceShutdown and InstanceShutdownByProviderID returned
NotImplemented. The node lifecycle controller could not tell a node
whose VM is stopped from one that is only unreachable, so it never
applied the node.cloudprovider.kubernetes.io/shutdown taint. With
InstancesV2 it also logged the NotImplemented error for every NotReady
node on each monitor period.

Both now look up the instance and report it shut down when its state
is Stopped. Stopping is not reported: the guest may still be running.
InstanceShutdown finds the instance by node name, as InstanceExists
does, so both checks look at the same VM.

Signed-off-by: Brad House <bhouse@nexthop.ai>
@bhouse-nexthop

Copy link
Copy Markdown
Author

Tested on a KVM lab with Apache CloudStack (a main / 24.0 build), Ceph RBD primary storage, and CKS clusters on Kubernetes 1.33.1. The CCM was deployed with the deployment.yaml from #118 (host network), once with the released v1.3.0 image (1 control, 1 worker) and once with an image built from this branch (1 control, 2 workers). In each run a worker VM that was not running the CCM pod was stopped from CloudStack, then started again.

Check v1.3.0 (15 of 15 passed) This branch (18 of 18 passed)
Stopped worker goes NotReady +54 s +53 s
node.cloudprovider.kubernetes.io/shutdown taint not set within 120 s set at +58 s
CCM log for the stopped node is shutdown: unimplemented (21 lines) no error
After the VM is started again Ready at +41 s, taint removed 3 s later
Control: kubelet stopped on a worker, VM still Running NotReady, no taint NotReady at +47 s, no taint 30 s later

The taint time follows the node monitor grace period (50 s on Kubernetes 1.33) plus one CCM monitor period.

Seen while testing, not caused by this change: the CCM runs as a single replica and its control-plane placement in the manifest is a preference, so the pod can be scheduled on a worker. In one run it was on the worker that was stopped, and no taint could be set until that worker came back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A node whose VM is stopped never gets the shutdown taint: InstanceShutdown is not implemented

1 participant